const ffmpeg = require('fluent-ffmpeg')
const ffmpegPath = require('@ffmpeg-installer/ffmpeg')
const ffprobePath = require('@ffprobe-installer/ffprobe')
const path = require('path')
const fs = require('fs')

// https://www.nxrte.com/jishu/47219.html
// https://cloud.tencent.com/developer/information/fluent-ffmpeg使用流媒体提取音频-ask
// https://blog.51cto.com/xutongbao/10644150
// https://hzhcontrols.com/new-2111147.html

// 定义视频文件路径
ffmpeg.setFfmpegPath(ffmpegPath.path)
ffmpeg.setFfprobePath(ffprobePath.path)

// 添加水印
ffmpeg(path.join(__dirname, './video/12.mp4'))
  .output(path.join(__dirname, 'aa.mp3')) // 输出文件
  .on('progress', (progress) => { // 监听切片进度
    console.log('Processing: ' + progress.percent + '% done')
  }).on('end', () => { // 监听结束
    console.log("视频切片完成")
  })
  .run(); // 执行